//
//  WelcomeController.m
//  999-考勤定位
//
//  Created by 李晓东 on 2018/4/7.
//  Copyright © 2018年 PeanutXu. All rights reserved.
//

#import "WelcomeController.h"
#import "ViewController.h"

#define kScreenWidth [UIScreen mainScreen].bounds.size.width
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
@interface WelcomeController ()
@property (nonatomic, strong) UIScrollView *scrollView;

@end

@implementation WelcomeController

- (void)loadView{
    [super loadView];
    CGRect rect = [UIScreen mainScreen].bounds;
    _scrollView = [[UIScrollView alloc]initWithFrame:[UIScreen mainScreen].bounds];
    [_scrollView setContentSize:CGSizeMake(rect.size.width * 4, rect.size.height)];
    [_scrollView setPagingEnabled:YES];
    [_scrollView setShowsHorizontalScrollIndicator:NO];
    [self.view addSubview:_scrollView];
    
    for (int i = 0; i < 4; i++) {
        UIImageView *imageView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"leadpage%d", i]]];
        [imageView setFrame:CGRectMake(i * kScreenWidth, 0, kScreenWidth, kScreenHeight)];
        
        [_scrollView addSubview:imageView];
    }
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setFrame:CGRectMake((kScreenWidth - 100) / 2 + kScreenWidth * 3, kScreenHeight - 50 - 60, 100, 50)];
    [button setTitle:@"Begin" forState:UIControlStateNormal];
    [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [button setBackgroundColor:[UIColor whiteColor]];

    [button addTarget:self action:@selector(jumpToHome:) forControlEvents:UIControlEventTouchUpInside];
    [_scrollView addSubview:button];
//    [self.view insertSubview:button aboveSubview:_scrollView];

    CGFloat jumpHeightPer = kScreenHeight / 42.5;
    UIButton *skipButton = [UIButton buttonWithType:UIButtonTypeCustom];
    [skipButton setFrame:CGRectMake((kScreenWidth - kScreenWidth * 0.2), kScreenHeight - jumpHeightPer * 7.5, 60, 30)];
    [skipButton addTarget:self action:@selector(jumpToHome:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:skipButton];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
 
}

- (void)jumpToHome:(id)sender {
//    id homeController = [self.storyboard instantiateViewControllerWithIdentifier:@"xxx"];
    UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    id homeController = [storyboard instantiateInitialViewController];
    self.view.window.rootViewController = homeController;
    
}


@end
